Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Conversation

@jmnsf
Copy link

@jmnsf jmnsf commented Nov 28, 2019

Adds the ability to send structs as events in log metadata:

Logger.info("Something happened", event: %AnEvent{with_data: true})

Right now, doing this raises an exception and the log message is dropped:

(FunctionClauseError) no function clause matching in Timber.Eventable.Any.to_event/1

Use case

I'm using struct events in my project to represent something happening in the app and its associated data. In the event handler for those events, I'm adding the event itself as context to all logging. It doesn't work though, because Timber can't convert it.

This PR uses the struct name as the context namespace for its logged contents.

@coveralls
Copy link

coveralls commented Nov 28, 2019

Pull Request Test Coverage Report for Build 915

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 42.373%

Totals Coverage Status
Change from base Build 885: 0.4%
Covered Lines: 200
Relevant Lines: 472

💛 - Coveralls

@jmnsf jmnsf force-pushed the eventable-structs branch from ea111ce to ea788b4 Compare November 28, 2019 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants